/* cROMFile.h
 * Wrapper for ROM file
 */
#ifndef __newmoon_cromfile_h
#define __newmoon_cromfile_h

class ROMFile;
#include <map>
#include <stdio.h>
#include <string>
#include <string.h> //strlen
#include <vector>
#include "debugout.h"
#include "uint.h"
#include "cSNESPointer.h"

class ROMFile {
	public:
		FILE *File;
		/* ObjectName assigns a name to each object in the game. The names are
		 * read from objnames.txt, but this is a member of ROMFile so that in
		 * the future each ROM may have its own list. The object ID used in the
		 * map is that returned from SMWObject::GetID().
		 */
		std::map<u32, std::string> ObjectName;
		/* LevelName holds the names read from levelnames.txt. It has nothing to
		 * do with level names stored in ROM.
		 */
		std::vector<std::string> LevelName;
		/* Internal name read from ROM, with trailing spaces trimmed and
		 * special characters URL-encoded. */
		std::string InternalName;
		
		ROMFile();
		ROMFile(std::string Filename);
		~ROMFile();
		bool Open(std::string Filename);
		bool ReadObjNames();
		bool ReadObjNames(std::string Filename);
		bool ReadLevelNames();
		bool ReadLevelNames(std::string Filename);
		void Seek(u32 Addr);
		void Seek(SNESPointer *Ptr);
		u32 GetPos();
		u8 Read();
		u8 Read(u32 Addr);
		u8 Read(SNESPointer *Ptr);
		u32 Read(u8 *Buf, u32 Size);
		u32 Read(u8 *Buf, u32 Size, u32 Addr);
		u32 Read(u8 *Buf, u32 Size, SNESPointer *Ptr);
		u8 ReadNoSeek(u32 Addr);
		u8 ReadNoSeek(SNESPointer *Ptr);
		u32 ReadNoSeek(u8 *Buf, u32 Size, u32 Addr);
		u32 ReadNoSeek(u8 *Buf, u32 Size, SNESPointer *Ptr);
	protected:
	
	private:
		void _Create(std::string Filename);
};
#endif //__newmoon_cromfile_h
